package ${implPackage};

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.stereotype.Service;
import ${entityPackage}.${entityName};
import ${mapperPackage}.${mapperName};
import ${servicePackage}.${serviceName};

/**
* ${tableComment}(table: ${tableName})接口实现
* @author ${author}
* @since ${date}
*/
@Service
public class ${implName} extends ServiceImpl<${mapperName},${entityName}>
 implements ${serviceName}{

    /**
     * 根据主键更新不为空的字段
     * @author ${author}
     * @since ${date}
     * @param entity:
     */
    @Override
    public void updateSelectiveById(${entityName} entity){
        LambdaUpdateWrapper<${entityName}> wrapper = new LambdaUpdateWrapper<>();
<#if primaryColumn?? && (primaryColumn?size >0)>
 <#list primaryColumn as column>
        wrapper.eq(${entityName}::get${column.javaFiled?cap_first},entity.get${column.javaFiled?cap_first}());
  </#list>
</#if>
<#if normalColumn?? && (normalColumn?size >0)>
 <#list normalColumn as column>
        if(entity.get${column.javaFiled?cap_first}() != null){
            wrapper.set(${entityName}::get${column.javaFiled?cap_first},entity.get${column.javaFiled?cap_first}());
        }
 </#list>
        update(wrapper);
</#if>
    }

}

